#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author： 青城子
# datetime： 2021/10/9 23:44 
# ide： PyCharm

class BootStrapForm:
    bootstrap_class_exclude = []

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            if name in self.bootstrap_class_exclude:
                continue
            old_class = field.widget.attrs.get("class", "")
            if name == "api_method":
                field.widget.attrs['class'] = "form-select-sm"
            else:
                field.widget.attrs['class'] = "{0} form-control".format(old_class)
                field.widget.attrs['placeholder'] = "请输入{0}".format(field.label)
